<template>
	<view class="pop-promot-box" catchtap="hidePromptboxTap">
		<view class="pop-promot-back" catchtap="return">
			<view class="pop-promot-bg">
				<view class="pop-promot-title">{{title}}</view>
				<view style="min-height: 66px;" :style="{'text-align': msgCenter}">
					<view class="pop-promot-count pop-promot-count2">{{msg}}</view>
				</view>
				<view class="pop-promot-bottomView">
					<view class="bottom-leftbtn defineButton" @click="fnTuichu()">退出</view>
					<view v-if="downtime==0" class="bottom-leftbtn defineButton" @click="fnTryagain()">重试</view>

					<view v-else class="bottom-leftbtn cancelButton">
						重试<text>({{downtime}})</text></view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		props: {
			confirmTitle: {
				type: String,
			},
			cancelTitle: {
				type: String
			},
			msg: {
				type: String,
				default: ''
			},
			title: {
				type: String,
				default: '提示'
			},
			showUserInfo: {
				type: Boolean,
				default: false
			},
			msgCenter: {
				type: String,
				default: 'left'
			}
		},
		data() {
			return {
				downtime: 0,
				timer: null
			}
		},
		methods: {
			fnTuichu: function() {
				this.$emit('tuichu');
			},
			fnTryagain: function(e) {
				var that = this;
				this.$emit('tryagain');
				if (this.timer) {
					clearInterval(this.timer)
					this.timer = null;
				}
				this.downtime = 8;
				this.timer = setInterval(() => {
					console.log('心跳！！！')
					if (that.downtime > 0) {
						that.downtime--;
					} else {
						clearInterval(this.timer)
						this.timer = null;
					}
				}, 1000)
			},
			confirm: function(e) {
				this.$emit('confirm');
			},
			to1() {
				uni.navigateTo({
					url: '/pages/tabbar/userCenter/userAgreement'
				})
			},
			to2() {
				uni.navigateTo({
					url: '/pages/tabbar/userCenter/privacyPolicy'
				})
			}
		}
	}
</script>

<style lang="less">
	.pop-promot-box {
		width: 100%;
		height: 100%;
		position: fixed;
		background-color: rgba(0, 0, 0, 0.5);
		z-index: 998;
		top: 0;
		left: 0;
		display: flex;
		justify-content: center;
		align-items: center;
	}

	.pop-promot-back {
		padding: 20px 15px;
		width: 80%;
		margin: 0 10%;
		border-radius: 10px;
		// background-image: url(https://cdn.spbcn.org/spbcnWechat/pop-content-back.png);

		background: linear-gradient(0deg, #130E00 0%, #373632 100%);
		color: #fff;
		box-sizing: border-box;
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
	}

	.pop-promot-bg {
		width: 100%;
		height: 100%;
		background-image: url(../static/image/homePage/diwen.png);
		background-size: cover;
	}

	.pop-promot-title {
		font-size: 18px;
		color: white;
		text-align: center;
		margin-bottom: 8px;
		font-family: 'hzgb';
		// text-shadow: -1px 1px 0 #992722, 1px 1px 0 #992722, 1px -1px 0 #992722, -1px -1px 0 #992722;
		// -webkit-text-stroke: 1px #992722;
	}

	.pop-promot-count {
		font-size: 14px;
		color: black;
		// text-align: center;
		font-weight: 600;
		padding: 0 10px;
		border-radius: 10px;
		margin-top: 5px;
		color: #fff;
	}

	.pop-promot-count1 {
		// text-align: left;
		// padding: 0;

		span {
			color: #ffd16b;
		}
	}

	.backColor {
		background-color: white;
	}

	.pop-promot-bottomView {
		width: 100%;
		height: 30px;
		display: flex;
		flex-direction: row;
		justify-content: space-around;
		margin-top: 15px;
	}

	.bottom-leftbtn {
		width: 120px;
		height: 32px;
		line-height: 32px;
		border-radius: 15px;
		font-size: 14px;
		text-align: center;
		// font-weight: 800;
	}

	.defineButton {
		color: #000;
		font-family: hzgb;
		background: linear-gradient(to bottom, #ffd16b, #fff497);
		box-shadow: 0px 6px 0px 0px #d9b059;
	}

	.cancelButton {
		color: #fff;
		font-family: hzgb;
		background: linear-gradient(to bottom, #130e00, #373632) !important;
		box-shadow: 0px 6px 0px 0px #9b8b6f;
	}

	.pop-promot-count2 {
		white-space: pre-line;
	}
</style>